<?php
include "include/config.inc.php";
if(isset($_POST['submit']))
{
  $partyCode   = isset($_REQUEST['partyCode']) ? $_REQUEST['partyCode'] : "";
  $addOn       = isset($_REQUEST['addOn']) ? $_REQUEST['addOn'] : "";
  $accountName = isset($_REQUEST['accountName']) ? $_REQUEST['accountName'] : "";
  $address     = isset($_REQUEST['address']) ? $_REQUEST['address'] : "";
  $gAddress    = isset($_REQUEST['gAddress']) ? $_REQUEST['gAddress'] : "";
  $mobile      = isset($_REQUEST['mobile']) ? $_REQUEST['mobile'] : 0;
  $photo       = isset($_REQUEST['photo']) ? $_REQUEST['photo'] : "";
  $otherInfo   = isset($_REQUEST['otherInfo']) ? $_REQUEST['otherInfo'] : "";
  
   
  if(isset($_FILES['photo']['name']) && $_FILES['photo']['name'] != "")
  {
    $filename  = pathinfo($_FILES['photo']['name']);
    $extension = $filename['extension'];
    $stamp     = strtotime($today);
    $image     = "partyImg_".$accountId."_".$stamp.".".$extension;
    $file      = "partyUplodeadImages/".$image;
    move_uploaded_file($_FILES['photo']['tmp_name'], $file); 
   
    $updateImage    = "UPDATE account
                          SET photo = '".$image."'
                        WHERE accountId = ".$accountId;
    $updateImageRes = mysql_query($updateImage);
    if(!$updateImageRes)
    {
      echo "Update Image Error : ".mysql_error();
    }      
  }
  
  $insertParty = "INSERT INTO `account` (`accountName`, `partyCode`, `address`, `mobile`, `photo`, `otherInfo`,`isParty`)
                        VALUES ('".$accountName."', '".$partyCode."', '".addslashes($address)."', '".$mobile."','".$_FILES['photo']['name']."',
                                '".$otherInfo."',1)";
  $insertPartyRes = mysql_query($insertParty);
  if(!$insertPartyRes)
  {
  	echo "Insert Fail";
  }
  else
  {
    header("Location:party.php");
  }
}
include("bottom.php");
$smarty->display('party.tpl');
?>
